| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- <template>
- <div id="newsList">
- <!-- 页面头部 -->
- <HomePageHead></HomePageHead>
- <!-- 导航栏 -->
- <HomePageNavigation1></HomePageNavigation1>
- <!-- 列表页广告一 -->
- <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
- <!-- 搜索框 -->
- <div class="search">
- <div class="inner">
- <input v-model="keywordInput" type="text" placeholder="请输入搜索内容">
- <button @click="goSearch">搜索</button>
- </div>
- </div>
- <div class="breadcrumb phone_none">
- <div class="inner">
- <span class="location">当前位置:</span>
- <el-breadcrumb :separator-icon="ArrowRight">
- <el-breadcrumb-item>
- <NuxtLink to="/">首页</NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item>搜索</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- </div>
-
- <div class="breadcrumb_box pc_none">
-
- <span class=" ">当前位置:</span>
-
- <NuxtLink to="/">首页</NuxtLink>
- <span class=" ">></span>
-
- <span class=" ">搜索</span>
-
- </div>
- <div class="newsList">
- <div class="inner">
- <div class="innerLeft">
- <ul class="list" v-if="newsList.length >= 0">
- <li v-for="(item, index) in newsList" :key="index">
- <NuxtLink :href="getLinkPathDetail(item)" :title="item.title"
- :target="item.islink == 1 ? '_blank' : '_self'">
- <span class="listText"> {{ item.title }}</span>
- <span class="time phone_none ">{{ getTime(item.updated_at, 'month', 1) }}</span>
- </NuxtLink>
- </li>
- </ul>
- <div v-if="newsList.length == 0" class="empty">
- <div>
- <img src="../../public/search/empty.png" alt="暂无内容">
- <p>暂无搜索数据</p>
- </div>
- </div>
- <!-- 分页器 -->
- <div class="pagination pagination_phone_none" v-if="total > 0">
- <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
- :page-size="pageSize" prev-text="上一页" next-text="下一页" @change="changePage" />
- </div>
-
- <div class="pagination pagination_pc_none" v-if="total > 0">
- <el-pagination
- pager-count="5"
- class="mt-4"
- size="small"
- background
- layout=" pager "
- :total="total"
- page-size="pageSize"
- @change="changePage"
- />
- </div>
- </div>
- </div>
- </div>
- <!-- 列表页广告二 -->
- <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
- <!-- 页面底部 -->
- <HomeFoot1></HomeFoot1>
- </div>
- </template>
- <script setup>
- //1.页面依赖 start ---------------------------------------->
- import { ElBreadcrumb, ElBreadcrumbItem, ElPagination } from 'element-plus'
- import { ArrowRight } from '@element-plus/icons-vue'
- import { ref, onMounted } from 'vue';
- const route = useRoute();
- //const pageCatids = route.query.catids;
- const pageCatids = ""
- if (route.params.id == 'search') {
- } else {
- const pageCatids = route.params.id
- }
- const pageDepartment_id = route.query.department_id;
- //const category_id = route.query.category_id; //获得该页面的id
- // const searchKey = route.query.keyword
- // const catids = ref([]);
- //关键词
- let total = useState("total", () => 0)
- let page = useState("page", () => 1)
- let pageSize = useState("pageSize", () => 20)
- //格式化跳转链接
- const getLinkPathDetail = (item) => {
- if (item.islink == 1) {
- return `${item.linkurl}`;
- } else {
- return `/${item.pinyin}/${item.id}.html`;
- }
- }
- //1.页面依赖 end ---------------------------------------->
- //2.页面数据 start ---------------------------------------->
- //2.1 广告
- let adImg1 = ref([]);
- let adImg2 = ref([]);
- onMounted(async () => {
- //从客户端获取行政职能部门 加快打开速度
- const { $webUrl, $CwebUrl } = useNuxtApp();
- //广告1
- let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmw_search_0001`
- const responseAd1 = await fetch(url, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd1 = await responseAd1.json();
- adImg1.value = resultAd1.data[0];
- //广告2
- let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nmw_search_0002`
- const responseAd2 = await fetch(url2, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd2 = await responseAd2.json();
- adImg2.value = resultAd2.data[0];
- })
- // 新闻列表
- const newsList = ref([]);
- let keywordInput = ref("");
- //搜索
- let goSearch = async () => {
- console.log(page.value)
- console.log(pageSize.value)
- console.log(keywordInput.value)
- console.log(pageCatids)
- console.log(pageDepartment_id)
- const listData = await requestDataPromise('/web/selectWebsiteCategory', {
- method: 'GET',
- query: {
- 'page': page.value,
- 'pageSize': pageSize.value,
- 'keyword': keywordInput.value,
- 'cityid': pageCatids,
- 'department_id': pageDepartment_id
- },
- });
- if (listData.data.rows) {
- console.log(listData)
- newsList.value = listData.data.rows;
- total.value = listData.data.count;
- } else {
- newsList.value = [];
- total.value = 0;
- }
- }
- goSearch();
- //基于导航池搜索
- // let goSearchFont = async (font) => {
- // const listData = await requestDataPromise('/web/getWebsiteArticleList', {
- // method: 'GET',
- // query: {
- // 'page': page.value,
- // 'pageSize': pageSize.value,
- // 'catid': font
- // },
- // });
- // newsList.value = listData.data.rows;
- // total.value = listData.data.count;
- // }
- // //基于导航池与关键词搜索
- // let goSearchFontandCid = async (font) => {
- // const listData = await requestDataPromise('/web/getWebsiteArticleList', {
- // method: 'GET',
- // query: {
- // 'page': page.value,
- // 'pageSize': pageSize.value,
- // 'catid': category_id,
- // 'keyword':searchKey
- // },
- // });
- // newsList.value = listData.data.rows;
- // total.value = listData.data.count;
- // }
- //直接查新闻
- // const newslists = async () => {
- // try {
- // // 从地区跳转
- // if (route.query.catids && route.query.catids.length > 0) {
- // // 将字符串转换回数组,并过滤掉可能的空值
- // catids.value = route.query.catids.split(',').filter(id => id);
- // if (catids.value.length > 0) {
- // // 有效的 catids 数组,可以进行后续操作
- // console.log('接收到的分类ID数组:', catids.value);
- // let font = catids.value.join(",")
- // font = "[" + font + "]"
- // goSearchFont(font);
- // } else {
- // // 处理空数组情况
- // console.log('未接收到有效的分类ID');
- // }
- // } else {
- // if (category_id == undefined) {
- // //直接搜索 默认进来没有导航池的话 不执行搜索
- // goSearch();
- // } else {
- // goSearchFontandCid();
- // }
- // }
- // } catch (error) {
- // console.error(error);
- // }
- // }
- // newslists();
- // 查询导航池的方法
- // const newslists = async () => {
- // try {
- // // 从地区跳转
- // if (route.query.catids && route.query.catids.length > 0) {
- // // 将字符串转换回数组,并过滤掉可能的空值
- // catids.value = route.query.catids.split(',').filter(id => id);
- // if (catids.value.length > 0) {
- // // 有效的 catids 数组,可以进行后续操作
- // console.log('接收到的分类ID数组:', catids.value);
- // let font = catids.value.join(",")
- // font = "[" + font + "]"
- // goSearchFont(font);
- // } else {
- // // 处理空数组情况
- // console.log('未接收到有效的分类ID');
- // }
- // } else {
- // if (category_id == undefined) {
- // //直接搜索 默认进来没有导航池的话 不执行搜索
- // goSearch();
- // } else {
- // goSearchFontandCid();
- // }
- // }
- // } catch (error) {
- // console.error(error);
- // }
- // }
- // newslists();
- //分页事件
- let changePage = (value) => {
- console.log("当前页码", value);
- page.value = value
- console.log(page.value);
- goSearch()
- }
- //2.页面数据 end ---------------------------------------->
- //4.设置seo信息 start---------------------------------------->
- //4.1 设置seo信息
- const setData = await requestDataPromise('/web/getWebsiteFootInfo', {
- method: 'GET',
- query: {},
- });
- let seoTitle = setData.data.website_head.title;
- let seoDescription = setData.data.website_head.description;
- let seoKeywords = setData.data.website_head.keywords;
- let seoSuffix = setData.data.website_head.suffix;
- let seoName = setData.data.website_head.website_name;
- useSeoMeta({
- title: seoTitle + "_" + seoSuffix,
- meta: [
- { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
- { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
- { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
- ]
- });
- //4.设置seo信息 end---------------------------------------->
- </script>
- <style lang="less" scoped>
- @import url('@/assets/css/search.less');
- </style>
- <style lang="less" scoped>
-
- @media screen and (min-width:801px){/*pc*/
-
- .pagination_pc_none{display:none!important;}
- .pc_none{display:none;}
- }
- @media screen and (max-width:800px){/*ipad_phone*/
- .breadcrumb{margin-bottom:10px; }
- .breadcrumb .location{ font-size: 14px; }
- .breadcrumb span { font-size: 14px; }
- .newsList{width:100%;margin-bottom:22px;}
- .newsList .inner{width:92%!important;}
- .newsList .inner .innerLeft > .list > li{width:96%;margin:0px auto;}
- .newsList .inner .innerLeft{width:100%;border-top:solid 1px #DD7D18;}
- .newsList .inner .innerLeft > .list > li{line-height:50px;}
-
-
- .newsList .inner .innerLeft > .list > li > a{
- width:100%;display:block; height:50px;line-height:50px;font-size:16px;
- word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
- }
-
- .newsList .inner .innerLeft > .list > li a{float:left;width:92%; }
- .newsList .inner .innerLeft > .list > li:nth-of-type(-n+2)::after{display: block;height:18px;margin:10px 0px 0px 0px;
- font-size:12px;line-height:18px;float:right;}
- .newsList .inner .innerLeft > .pagination{width:100%;}
- .newsList .inner .innerLeft > .list{margin:10px auto 10px;}
- .newsList .inner .innerLeft > .pagination{margin-bottom:11px;}
- .newsList .inner .innerRight {width:100%;display:none;}
- .index_foot{margin-top:11px;}
- .search{ overflow:hidden;height:auto;
- width:92%;margin:10px auto;
-
- .inner{width:100%;display:flex;height:auto;padding:0;}
- .inner > input{ flex:1;width:auto;line-height:33px;height:33px;box-sizing:border-box;font-size:14px;}
- .inner > button{width:auto;padding:0px 8px;line-height:33px;height:33px;font-size:14px;}
- }
-
- ::v-deep .el-pager li{
- margin:0px 4px!important;
- }
- .advert_box{width:92%;margin:0px auto;}
- .pagination_phone_none{display:none!important;}
- .newsList .inner .innerLeft > .list > li{line-height:40px;height:40px;}
- .newsList .inner .innerLeft > .list > li a{line-height:40px;height:40px;}
-
-
- .newsList .inner .innerLeft > .list > li:nth-child(5n){
- height:auto;
- padding-bottom:11px;
- margin-bottom:11px;
- }
- .breadcrumb_box{
- height:22px;width:100%;margin:10px auto;
- word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
- width:92%;
- font-size:14px;
- color:#666;
-
- *{
- font-size:14px;
-
- display:inline ;
- color:#666;
- line-height:22px;height:22px;
- margin-right:5px;
- }
- }
- .newsList .inner .innerLeft .list li .listText{width:100%;}
- .newsDetail .inner .innerLeft .LeftTop > p{height:auto;}
- .phone_none{display:none;}
-
- }
- </style>
|